<!DOCTYPE html><html><head>
<title>namespacex - Namespace utility commands</title>
<style type="text/css"><!--
    HTML {
	background: 	#FFFFFF;
	color: 		black;
    }
    BODY {
	background: 	#FFFFFF;
	color:	 	black;
    }
    DIV.doctools {
	margin-left:	10%;
	margin-right:	10%;
    }
    DIV.doctools H1,DIV.doctools H2 {
	margin-left:	-5%;
    }
    H1, H2, H3, H4 {
	margin-top: 	1em;
	font-family:	sans-serif;
	font-size:	large;
	color:		#005A9C;
	background: 	transparent;
	text-align:		left;
    }
    H1.doctools_title {
	text-align: center;
    }
    UL,OL {
	margin-right: 0em;
	margin-top: 3pt;
	margin-bottom: 3pt;
    }
    UL LI {
	list-style: disc;
    }
    OL LI {
	list-style: decimal;
    }
    DT {
	padding-top: 	1ex;
    }
    UL.doctools_toc,UL.doctools_toc UL, UL.doctools_toc UL UL {
	font:		normal 12pt/14pt sans-serif;
	list-style:	none;
    }
    LI.doctools_section, LI.doctools_subsection {
	list-style: 	none;
	margin-left: 	0em;
	text-indent:	0em;
	padding: 	0em;
    }
    PRE {
	display: 	block;
	font-family:	monospace;
	white-space:	pre;
	margin:		0%;
	padding-top:	0.5ex;
	padding-bottom:	0.5ex;
	padding-left:	1ex;
	padding-right:	1ex;
	width:		100%;
    }
    PRE.doctools_example {
	color: 		black;
	background: 	#f5dcb3;
	border:		1px solid black;
    }
    UL.doctools_requirements LI, UL.doctools_syntax LI {
	list-style: 	none;
	margin-left: 	0em;
	text-indent:	0em;
	padding:	0em;
    }
    DIV.doctools_synopsis {
	color: 		black;
	background: 	#80ffff;
	border:		1px solid black;
	font-family:	serif;
	margin-top: 	1em;
	margin-bottom: 	1em;
    }
    UL.doctools_syntax {
	margin-top: 	1em;
	border-top:	1px solid black;
    }
    UL.doctools_requirements {
	margin-bottom: 	1em;
	border-bottom:	1px solid black;
    }
--></style>
</head>
<!-- Generated from file 'namespacex.man' by tcllib/doctools with format 'html'
   -->
<!-- Copyright &amp;copy; 200? Neil Madden (http://wiki.tcl.tk/12790)   -- Copyright &amp;copy; 200? Various (http://wiki.tcl.tk/1489)   -- Copyright &amp;copy; 2010 Documentation, Andreas Kupries
   -->
<!-- namespacex.n
   -->
<body><hr> [
   <a href="../../../../../../../../home">Tcllib Home</a>
&#124; <a href="../../../../toc.html">Main Table Of Contents</a>
&#124; <a href="../../../toc.html">Table Of Contents</a>
&#124; <a href="../../../../index.html">Keyword Index</a>
&#124; <a href="../../../../toc0.html">Categories</a>
&#124; <a href="../../../../toc1.html">Modules</a>
&#124; <a href="../../../../toc2.html">Applications</a>
 ] <hr>
<div class="doctools">
<h1 class="doctools_title">namespacex(n) 0.2 tcllib &quot;Namespace utility commands&quot;</h1>
<div id="name" class="doctools_section"><h2><a name="name">Name</a></h2>
<p>namespacex - Namespace utility commands</p>
</div>
<div id="toc" class="doctools_section"><h2><a name="toc">Table Of Contents</a></h2>
<ul class="doctools_toc">
<li class="doctools_section"><a href="#toc">Table Of Contents</a></li>
<li class="doctools_section"><a href="#synopsis">Synopsis</a></li>
<li class="doctools_section"><a href="#section1">Description</a></li>
<li class="doctools_section"><a href="#section2">Commands</a></li>
<li class="doctools_section"><a href="#section3">Bugs, Ideas, Feedback</a></li>
<li class="doctools_section"><a href="#keywords">Keywords</a></li>
<li class="doctools_section"><a href="#copyright">Copyright</a></li>
</ul>
</div>
<div id="synopsis" class="doctools_section"><h2><a name="synopsis">Synopsis</a></h2>
<div class="doctools_synopsis">
<ul class="doctools_requirements">
<li>package require <b class="pkgname">Tcl 8.5</b></li>
<li>package require <b class="pkgname">namespacex <span class="opt">?0.2?</span></b></li>
</ul>
<ul class="doctools_syntax">
<li><a href="#1"><b class="cmd">::namespacex hook add</b> <span class="opt">?<i class="arg">namespace</i>?</span> <i class="arg">cmdprefix</i></a></li>
<li><a href="#2"><b class="cmd">::namespacex hook proc</b> <span class="opt">?<i class="arg">namespace</i>?</span> <i class="arg">arguments</i> <i class="arg">body</i></a></li>
<li><a href="#3"><b class="cmd">::namespacex hook on</b> <span class="opt">?<i class="arg">namespace</i>?</span> <i class="arg">guardcmdprefix</i> <i class="arg">actioncmdprefix</i></a></li>
<li><a href="#4"><b class="cmd">::namespacex hook next</b> <i class="arg">arg</i>...</a></li>
<li><a href="#5"><b class="cmd">::namespacex import fromns</b> <i class="arg">cmdname <span class="opt">?<i class="arg">newname</i> ...?</span></i></a></li>
<li><a href="#6"><b class="cmd">::namespacex info allchildren</b> <i class="arg">namespace</i></a></li>
<li><a href="#7"><b class="cmd">::namespacex info allvars</b> <i class="arg">namespace</i></a></li>
<li><a href="#8"><b class="cmd">::namespacex normalize</b> <i class="arg">namespace</i></a></li>
<li><a href="#9"><b class="cmd">::namespacex info vars</b> <i class="arg">namespace</i> <span class="opt">?<i class="arg">pattern</i>?</span></a></li>
<li><a href="#10"><b class="cmd">::namespacex state get</b> <i class="arg">namespace</i></a></li>
<li><a href="#11"><b class="cmd">::namespacex state set</b> <i class="arg">namespace</i> <i class="arg">dict</i></a></li>
<li><a href="#12"><b class="cmd">::namespacex state drop</b> <i class="arg">namespace</i></a></li>
<li><a href="#13"><b class="cmd">::namespacex strip</b> <i class="arg">prefix</i> <i class="arg">namespaces</i></a></li>
</ul>
</div>
</div>
<div id="section1" class="doctools_section"><h2><a name="section1">Description</a></h2>
<p>This package provides a number of utility commands for working with
namespaces.
The commands fall into four categories:</p>
<ol class="doctools_enumerated">
<li><p>Hook commands provide and manipulate a chain of commands which
replaces the single regular <b class="cmd"><a href="../../../../index.html#namespace_unknown">namespace unknown</a></b> handler.</p></li>
<li><p>An import command provides the ability to import any command
from another namespace.</p></li>
<li><p>Information commands allow querying of variables and child
namespaces.</p></li>
<li><p>State commands provide a means to serialize variable values in
a namespace.</p></li>
</ol>
</div>
<div id="section2" class="doctools_section"><h2><a name="section2">Commands</a></h2>
<dl class="doctools_definitions">
<dt><a name="1"><b class="cmd">::namespacex hook add</b> <span class="opt">?<i class="arg">namespace</i>?</span> <i class="arg">cmdprefix</i></a></dt>
<dd><p>Adds the <i class="arg">cmdprefix</i> to the chain of unknown command handlers that
are invoked when the <i class="arg">namespace</i> would otherwise invoke its
unknown handler.
If <i class="arg">namespace</i> is not specified, then <i class="arg">cmdprefix</i> is added to
the chain of handlers for the namespace of the caller.</p>
<p>The chain of <i class="arg">cmdprefix</i> are executed in reverse order of
addition, <em>i.e.</em> the most recently added <i class="arg">cmdprefix</i> is
executed first.
When executed, <i class="arg">cmdprefix</i> has additional arguments appended to it
as would any namespace unknown handler.</p></dd>
<dt><a name="2"><b class="cmd">::namespacex hook proc</b> <span class="opt">?<i class="arg">namespace</i>?</span> <i class="arg">arguments</i> <i class="arg">body</i></a></dt>
<dd><p>Adds an anonymous procedure to the chain of namespace unknown handlers
for the <i class="arg">namespace</i>.</p>
<p>If <i class="arg">namespace</i> is not specified, then the handler is added
to the chain of handlers for the namespace of the caller.</p>
<p>The <i class="arg">arguments</i> and <i class="arg">body</i> are specified as for the
core <b class="cmd"><a href="../../../../index.html#proc">proc</a></b> command.</p></dd>
<dt><a name="3"><b class="cmd">::namespacex hook on</b> <span class="opt">?<i class="arg">namespace</i>?</span> <i class="arg">guardcmdprefix</i> <i class="arg">actioncmdprefix</i></a></dt>
<dd><p>Adds a guarded action to the chain of namespace unknown handlers for
the <i class="arg">namespace</i>.</p>
<p>If <i class="arg">namespace</i> is not specified, then the handler is added
to the chain of handlers for the namespace of the caller.</p>
<p>The <i class="arg">guardcmdprefix</i> is executed first. If it returns a
value that can be interpreted as false, then the next unknown hander
in the chain is executed. Otherwise, <i class="arg">actioncmdprefix</i> is executed
and the return value of the handler is the value returned by
<i class="arg">actioncmdprefix</i>.</p>
<p>When executed, both <i class="arg">guardcmdprefix</i> and
<i class="arg">actioncmdprefix</i> have the same additional arguments appended as
for any namespace unknown handler.</p></dd>
<dt><a name="4"><b class="cmd">::namespacex hook next</b> <i class="arg">arg</i>...</a></dt>
<dd><p>This command is available to namespace hooks to execute the next hook
in the chain of handlers for the namespace.</p></dd>
<dt><a name="5"><b class="cmd">::namespacex import fromns</b> <i class="arg">cmdname <span class="opt">?<i class="arg">newname</i> ...?</span></i></a></dt>
<dd><p>Imports the command <i class="arg">cmdname</i> from the <i class="arg">fromns</i> namespace into
the namespace of the caller.
The <i class="arg">cmdname</i> command is imported even if the <i class="arg">fromns</i> did not
originally export the command.</p>
<p>If <i class="arg">newname</i> is specified, then the imported command will
be known by that name. Otherwise, the command retains is original name
as given by <i class="arg">cmdname</i>.</p>
<p>Additional pairs of <i class="arg">cmdname</i> / <i class="arg">newname</i> arguments may
also be specified.</p></dd>
<dt><a name="6"><b class="cmd">::namespacex info allchildren</b> <i class="arg">namespace</i></a></dt>
<dd><p>Returns a list containing the names of all child namespaces in the
specified <i class="arg">namespace</i> and its children. The names are all fully
qualified.</p></dd>
<dt><a name="7"><b class="cmd">::namespacex info allvars</b> <i class="arg">namespace</i></a></dt>
<dd><p>Returns a list containing the names of all variables in the specified
<i class="arg">namespace</i> and its children. The names are all given relative to
<i class="arg">namespace</i>, and <em>not</em> fully qualified.</p></dd>
<dt><a name="8"><b class="cmd">::namespacex normalize</b> <i class="arg">namespace</i></a></dt>
<dd><p>Returns the absolute name of <i class="arg">namespace</i>, which is resolved
relative to the namespace of the caller, with all unneeded colon
characters removed.</p></dd>
<dt><a name="9"><b class="cmd">::namespacex info vars</b> <i class="arg">namespace</i> <span class="opt">?<i class="arg">pattern</i>?</span></a></dt>
<dd><p>Returns a list containing the names of all variables in
the specified <i class="arg">namespace</i>.
If the <i class="arg">pattern</i> argument is specified, then only variables
matching <i class="arg">pattern</i> are returned. Matching is determined using the
same rules as for <b class="cmd">string match</b>.</p></dd>
<dt><a name="10"><b class="cmd">::namespacex state get</b> <i class="arg">namespace</i></a></dt>
<dd><p>Returns a dictionary holding the names and values of all variables in
the specified <i class="arg">namespace</i> and its child namespaces.</p>
<p>Note that the names are all relative to <i class="arg">namespace</i>, and
<em>not</em> fully qualified.</p></dd>
<dt><a name="11"><b class="cmd">::namespacex state set</b> <i class="arg">namespace</i> <i class="arg">dict</i></a></dt>
<dd><p>Takes a dictionary holding the names and values for a set of variables
and replaces the current state of the specified <i class="arg">namespace</i> and
its child namespaces with this state.
The result of the command is the empty string.</p></dd>
<dt><a name="12"><b class="cmd">::namespacex state drop</b> <i class="arg">namespace</i></a></dt>
<dd><p>Unsets all variables in the specified <i class="arg">namespace</i> and its child
namespaces.
The result of the command is the empty string.</p></dd>
<dt><a name="13"><b class="cmd">::namespacex strip</b> <i class="arg">prefix</i> <i class="arg">namespaces</i></a></dt>
<dd><p>Each item in <i class="arg">namespaces</i> must be the absolute normalized name of
a child namespace of namespace <i class="arg">prefix</i>.
Returns the corresponding list of relative names of child namespaces.</p></dd>
</dl>
</div>
<div id="section3" class="doctools_section"><h2><a name="section3">Bugs, Ideas, Feedback</a></h2>
<p>This document, and the package it describes, will undoubtedly contain
bugs and other problems.
Please report such in the category <em>namespacex</em> of the
<a href="http://core.tcl.tk/tcllib/reportlist">Tcllib Trackers</a>.
Please also report any ideas for enhancements you may have for either
package and/or documentation.</p>
<p>When proposing code changes, please provide <em>unified diffs</em>,
i.e the output of <b class="const">diff -u</b>.</p>
<p>Note further that <em>attachments</em> are strongly preferred over
inlined patches. Attachments can be made by going to the <b class="const">Edit</b>
form of the ticket immediately after its creation, and then using the
left-most button in the secondary navigation bar.</p>
</div>
<div id="keywords" class="doctools_section"><h2><a name="keywords">Keywords</a></h2>
<p><a href="../../../../index.html#extended_namespace">extended namespace</a>, <a href="../../../../index.html#info">info</a>, <a href="../../../../index.html#namespace_unknown">namespace unknown</a>, <a href="../../../../index.html#namespace_utilities">namespace utilities</a>, <a href="../../../../index.html#state_de_serialization">state (de)serialization</a>, <a href="../../../../index.html#unknown_hooking">unknown hooking</a>, <a href="../../../../index.html#utilities">utilities</a></p>
</div>
<div id="copyright" class="doctools_section"><h2><a name="copyright">Copyright</a></h2>
<p>Copyright &copy; 200? Neil Madden (http://wiki.tcl.tk/12790)<br>
Copyright &copy; 200? Various (http://wiki.tcl.tk/1489)<br>
Copyright &copy; 2010 Documentation, Andreas Kupries</p>
</div>
</div></body></html>
